﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Dropthings.DataAccess;

namespace Dropthings.Business.Activities.WidgetActivities
{
	public partial class GetWidgetInstanceActivity: Activity
	{
        public int WidgetInstanceId
        {
            get { return (int)GetValue(WidgetInstanceIdProperty); }
            set { SetValue(WidgetInstanceIdProperty, value); }
        }

        public static readonly DependencyProperty WidgetInstanceIdProperty =
            DependencyProperty.Register("WidgetInstanceId", typeof(int), typeof(GetWidgetInstanceActivity));



        public WidgetInstance WidgetInstance
        {
            get { return (WidgetInstance)GetValue(WidgetInstanceProperty); }
            set { SetValue(WidgetInstanceProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty WidgetInstanceProperty =
            DependencyProperty.Register("WidgetInstance", typeof(WidgetInstance), typeof(GetWidgetInstanceActivity));



        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.WidgetInstance = DatabaseHelper.GetSingle<WidgetInstance, int>(DatabaseHelper.SubsystemEnum.WidgetInstance,
                this.WidgetInstanceId, LinqQueries.CompiledQuery_GetWidgetInstanceById);

            return ActivityExecutionStatus.Closed;
        }

		public GetWidgetInstanceActivity()
		{
			InitializeComponent();
		}
	}
}
